package com.shujia

object Demo7ScalaExtend {
  def main(args: Array[String]): Unit = {
    val b: B = new B("001","张三",25)
    println(b.toString)
  }
}


class A(id:String,name:String){
  println("A的构造方法")
  //定义即复制
  val _id:String=id
  val _name:String=name

  override def toString = s"A(${_id}, ${_name})"
}


/**
  * 继承还是使用extends关键字
  * 但是在继承就需要调用父类的构造方法
  */
class B(id:String,name:String,age:Int) extends A(id,name){
  println("B中的构造方法")
  val _age:Int=age

  override def toString = s"B(${_age},${_name},${_age})"
}
